
package com.zsrt.day20170504.ch07;

public class Producer extends Thread{

	private Integer count;
	public Producer(int c){
		count = c;
	}
	
	public String sell(String name) {
		if(count<=20  && count>=2){
			System.out.println(Thread.currentThread().getName()+"买入成功");
			count--;
			if(count>=2){
				
				return name+"购买成功，剩余"+count;
			}else{
				System.out.println("货源不足");
				return null;
			}
		}else if(count>20){
			System.out.println("生产过多");
		}
		return null;
	}
}
